﻿using Mobileterminal.Common;
using Mobileterminal.Dtos;
using Org.BouncyCastle.Asn1.Cmp;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using B.S.Sterilizationcenter.Domain;
namespace Mobileterminal.Forms.Zyy
{
    public partial class GETDepartmentQuerys : UIPage
    {
    //    private System.ComponentModel.IContainer components = null;

        public GETDepartmentQuerys()
        {
            InitializeComponent();           
        }

        private void GETDepartmentQuerys_Load_1(object sender, EventArgs e)
        {
            GetData();

            // 1. 从数据库查询数据（示例）
            var records = new List<DepartmentQueryss>
            {
                new DepartmentQueryss { WarehousingTime = DateTime.Parse("2023-10-15 15:10:12"), Itemtype = "异常", Itemname = "张三" },
                new DepartmentQueryss { WarehousingTime = DateTime.Parse("2023-10-14 14:10:12"), Itemtype = "包装", Itemname = "张三" },
                new DepartmentQueryss { WarehousingTime = DateTime.Parse("2023-10-13 13:10:12"), Itemtype = "存放", Itemname = "张三" },
                new DepartmentQueryss { WarehousingTime = DateTime.Parse("2023-10-12 12:10:12"), Itemtype = "灭菌审核", Itemname = "张三" },
                new DepartmentQueryss { WarehousingTime = DateTime.Parse("2023-10-11 11:10:12"), Itemtype = "灭菌完成", Itemname = "张三" },
                new DepartmentQueryss { WarehousingTime = DateTime.Parse("2023-10-10 10:10:12"), Itemtype = "发放接收", Itemname = "张三" },
                new DepartmentQueryss { WarehousingTime = DateTime.Parse("2023-10-09 17:58:10"), Itemtype = "开始灭菌", Itemname = "张三" }
            };
            // 3. 绑定到控件
            timelineControl1.LoadData(records);
        } 
        private async Task GetData()
        {

            var url = "https://localhost:7224/api/DepartmentQuery/GetDepartmentQuery";
            var json = await HttpClientHelper.ClientAsync("GET", url);
            var result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result<List<DepartmentQueryss>>>(json);
            if (result?.Code == 200)
            {
                foreach (var item in result.Data)
                {
                    item.StatusName = item.Status == 1 ? "消毒中" : "已完成";
                }
                科室查询.DataSource = result.Data;

            }

        }
        private void uiDataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void GETDepartmentQuerys_Initialize(object sender, EventArgs e)
        {

        }
        /// <summary>
        ///  Required designer variable.
        /// </summary>
      

        /// <summary>
        ///  Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void timelineControl1_Paint(object sender, PaintEventArgs e)
        {

        }

    }


}

